package com.day19.Stream;

import java.io.*;

public class ObjectStreamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException
    {
        read();
    }
    private static void read() throws IOException, ClassNotFoundException
    {
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("myObjectStream\\student.txt"));
        Object obj=ois.readObject();
        Student s=(Student) obj;
        System.out.println(s.getName()+","+s.getAge());
        ois.close();
    }
    private static void write() throws IOException
    {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("myObjectStream\\student.txt"));
        Student s=new Student("张三",20);
        oos.writeObject(s);
        oos.close();
    }
}
